using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;
using SalesPoint.Model;

namespace SalesPoint.Converters
{
  public class ProductTypeToBoolConverter : IValueConverter
  {
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
      if (value == null) 
        return false;
      
      return ((ProductType) value) == ProductType.Discontinued;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
      if (value == null)
        return ProductType.Active;
      
      return (bool)value ? ProductType.Discontinued : ProductType.Active;
    }
  }
}
